function [bcol lcol] = getDartBoard(I)
%GETDARTBOARD returns the column number BCOL of the dart board boundaries 
%   and the column number LCOL of the boundaries of field 20 or 11
%   in image I.

% Project:  Dart detection [Bildfolgen LU]@CVL/TUWIEN
% Author:   Thomas Rittler
% Date:     05/2011

% thresholds
TH_VP = 50;
TH_HP = 400;

I = rgb2i1i2i3(I);  % convert to I1I2I3 color space

board = ~im2bw(I(:,:,3));       % using I3 channel for segmentation
board = bwareaopen(board, 30000, 8);
b = board;          % for field 20 or 11
board = bwfill(board, 'holes');
vp = sum(board);    % vertical profile
board(:, vp<TH_VP) = 0;
hp = sum(board,2);  % horizontal profile
board(hp<TH_HP, :) = 0; 

[xx, hfir] = find(board, 1, 'first');
[xx, hlast] = find(board, 1, 'last');

bcol = [hfir hlast];

% get lines for field 20 or 11
DELTA = 36;
se = strel('line', DELTA, 90);

ix = find(sum(b,2));
b(ix(1):ix(1)+DELTA, :) = 0;
b(ix(end)-DELTA:ix(end), :) = 0;
b = imerode(b, se);
b(:, sum(b)<5) = 0; 

b = sum(b);
b = ~b;
b(1:hfir+DELTA*2) = 0;
b(hlast-DELTA*2:end) = 0;
lidx = find(b);
tidx = find(diff(lidx)~=1);
try
    lcol = [median(lidx(1:tidx(1)-1)) median(lidx(tidx(end)+1:end))];
catch
    lcol = [1 1];
end
end